package org.yelongframework.mvel2;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.yelongframework.commons.lang.ArrayUtil;
import org.yelongframework.commons.lang.StringUtil;
import org.yelongframework.commons.time.DateUtil;
import org.yelongframework.core.util.map.AttrMap;

/**
 * MVEL工具
 * 
 * @since 1.0.0
 */
public final class MvelUtil {

	private MvelUtil() {
	}

	/**
	 * 创建一个通用的上下文
	 * 
	 * @return 通用的上下文
	 */
	public static Map<String, Object> createGenericContext() {
		AttrMap attrMap = new AttrMap();
		// java.util
		attrMap.put("Arrays", Arrays.class);
		attrMap.put("List", List.class);
		attrMap.put("ArrayList", ArrayList.class);
		attrMap.put("Map", Map.class);
		attrMap.put("HashMap", HashMap.class);
		attrMap.put("LinkedHashMap", LinkedHashMap.class);
		// java.util.stream
		attrMap.put("Collectors", Collectors.class);
		// 日期
		attrMap.put("Date", Date.class);
		attrMap.put("DateUtil", DateUtil.class);
		attrMap.put("DateUtils", DateUtils.class);
		attrMap.put("DateFormatUtils", DateFormatUtils.class);
		// 字符串
		attrMap.put("StringUtil", StringUtil.class);
		attrMap.put("StringUtils", StringUtils.class);
		// 集合
		attrMap.put("ArrayUtil", ArrayUtil.class);
		attrMap.put("CollectionUtils", CollectionUtils.class);
		return attrMap;
	}

}
